package com.liuwa.openapi.controller;

import com.liuwa.common.core.domain.Result;
import com.liuwa.common.utils.bean.BeanUtils;
import com.liuwa.knowledge.domain.Book;
import com.liuwa.knowledge.query.BookQuery;
import com.liuwa.knowledge.service.BookService;
import com.liuwa.openapi.common.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 教材Controller
 * 
 * @author liuwa
 * @date 2025-04-02 08:46:14
 */
@RestController
@Api(value = "教材")
@RequestMapping("/openapi/books")
public class OpenapiBookController extends BaseController {

    @Autowired
    private BookService bookService;

    /**
     * 查询教材列表
     */
    @ApiOperation("查询教材列表")
    @GetMapping
    public Result.ItemsVo list(BookQuery query)
    {
        Book condition = new Book();
        BeanUtils.copyBeanNotNull2Bean(query, condition);
        List<Book> items = bookService.findList(condition);
        return Result.items(items);
    }

    /**
     * 获取教材详细信息
     */
    @ApiOperation("获取教材详细信息")
    @GetMapping(value = "/{id}")
    public Book get(@PathVariable("id") Integer id)
    {
        return bookService.get(id);
    }




}
